package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.Role;
import com.zzyl.entity.RoleResource;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper {
    Page<Role> queryPage(String roleName);

    void insert(Role role);

    @Select("select distinct resource_no from sys_role_resource where role_id = #{roleId}")
    List<String> findCheckedResourcesByRoleId(Long roleId);

    void update(Role role);

    @Delete("DELETE FROM sys_role_resource where role_id = #{id}")
    void deleAllByRoleId(Long id);

    void insertRoleAndResource(RoleResource roleResource);
}
